package pattern.behavioral.memento.simple;

/**
 * @author: chaoyang.ren  
 * @date:Jun 16, 2017  
 * @time:3:52:24 PM   
 * @email:chaoyang.ren@foxmail.com  
 * @version: 1.0
 */
public class Test {
	public static void main(String[] args) {
		Game game = new Game();
        HeroState hState = new HeroState();
        hState.setHealthPoint(100);
        hState.setMagicPoint(100);
        game.setHeroState(hState);
        System.out.println("游戏状态备份开始");
        GameMemento memento = game.createMemento();
        Caretaker ct = new Caretaker();
        ct.setMemento(memento);
        System.out.println("游戏状态备份完成");
        System.out.println("开始游戏，当前英雄生命值：" + game.getHeroState().getHealthPoint());
        game.play();
        System.out.println("游戏结束，当前英雄生命值：" + game.getHeroState().getHealthPoint());
        System.out.println("游戏状态还原开始");
        game.restore(ct.getMemento());
        System.out.println("游戏状态还原结束");
        System.out.println("当前英雄生命值：" + game.getHeroState().getHealthPoint());
	}
}

